#ifndef MESSAGE_PASSING_H
#define MESSAGE_PASSING_H

#include "process_management.h"

#define MAX_NUMBER_MESSAGES 20
#define MAX_LENGTH_DATA 50

/* datastructures */

/* At the beginning, the fixed length of a message's data is 50 characters */
typedef struct{
	uint32_t from;
	uint32_t priority;
	char data[MAX_LENGTH_DATA];
}message;


/* functions declarations */

/* sends the message to the process identified by pid and returns 1 if the operation has been done successfully, 0 otherwise */ 
int send(uint32_t pid, message mess);

/* gets the first message from pid, blocking call */
void receive_from(uint32_t from, message* mess);

/* gets the first message with the correct priority, blocking call */
void receive_priority(uint32_t priority,message* mess);

/* waits for a message to arrive during timeouts units of time, returns 1 if a message has arrived, 0 otherwise */
int receive_timeout(int timeout, message* mess); 


#endif
